class GroupsSection < ActiveRecord::Base
  has_many :groups
  
  def count_available_groups(member)
  	
  	available_groups = 0
  	
  	self.groups.each do |group|
  		if member and group.permission.id >= member.permission.id
  			available_groups += 1  			
  		end
  		
  		if !member and group.permission.id >= 5
  			available_groups += 1
  		end
  	end
  	
  	return available_groups
  	
  end
end
